package fair.jobs;

import fair.constant.RedisConstant;
import fair.utils.QiNiuUtils;
import org.springframework.beans.factory.annotation.Autowired;
import redis.clients.jedis.JedisPool;

import java.util.Set;

/**
 * @author fair_wu
 * @version v1.0
 * @date 2021-01-26 下午 23:03
 */
public class ClearImgJob {

    @Autowired
    private JedisPool jedisPool;

    public void clearImg() {
        Set<String> set = jedisPool.getResource().sdiff(RedisConstant.SETMEAL_PIC_RESOURCES, RedisConstant.SETMEAL_PIC_DB_RESOURCES);
        if (set != null) {
            for (String name : set) {
                QiNiuUtils.delete(name);
                jedisPool.getResource().srem(RedisConstant.SETMEAL_PIC_RESOURCES, name);
            }
        }
    }
}
